<template>
  <el-dialog
    v-el-drag-dialog="{updataFull, updataDialogWidth}"
    :fullscreen="isfullscreen"
    :append-to-body="true"
    :width="setDialogWidth('800px')"
    :visible="visible"
    :title="$t('BIZ_FUNC_OTDR_TEST_RESULT')"
    @open="open"
    @close="close"
  >
    <el-table ref="tableBox" border :data="tableData">
      <template slot="empty">
        <NullData />
      </template>
      <el-table-column type="index" :label="$t('SEQUENCE')" :width="resetSize(60)" align="center" />
      <el-table-column :label="$t('TEST_TIME')" prop="testTime" min-width="150" />
      <el-table-column :label="$t('TESTING_DIRECTION')" prop="testTime" min-width="150">
        <template slot-scope="scope">
          {{
            scope.row.portList[0] && scope.row.portList[0].testDirection === 'A'
              ? $t('A_END')
              : $t('Z_END')
          }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('OTDR_TEST_RESULT')" min-width="150">
        <template slot-scope="scope">
          <el-button type="text" size="mini" @click="showTestChannel(scope.row)">{{
            $t('VIEW')
          }}</el-button>
        </template>
      </el-table-column>
    </el-table>
    <template v-slot:footer>
      <el-button @click="close">{{ $t('CLOSE') }}</el-button>
    </template>
  </el-dialog>
</template>
<script>
  import bizOpenApi from '@/api/oen/BizOpenApi'

  export default {
    props: {
      visible: {
        type: Boolean,
        default: false
      },
      rowData: {
        type: Object,
        default: () => {}
      }
    },
    data() {
      return {
        tableData: []
      }
    },
    computed: {},
    created() {},
    methods: {
      open() {
        bizOpenApi.getTestList({ bizId: this.rowData.bizId }).then(res => {
          this.tableData = res
        })
      },
      showTestChannel(row) {
        console.log('-showTestChannel---------', row)
        this.$emit('showTestChannel', row)
      },
      close() {
        this.$emit('update:visible')
      }
    }
  }
</script>
<style lang="scss" scoped></style>
